from stores.Store import Store
class MemStore(Store):
    def __init__(self):
        self._mem = {}

    def put(self, key, value):
        if key in self._mem:
            return False
        self._mem[key] = value
        return True

    def get(self, key):
        if key in self._mem:
            return self._mem[key]
        raise KeyError('Cannot find key %s' % key)


    def delete(self, key):
        if key in self._mem:
            self._mem.pop(key)
        raise KeyError('Cannot find key %s' % key)

    def flush(self):
        pass


    def close(self):
        self._mem = None

    